package com.baidu.bos.web.action;

import java.util.List;

import javax.annotation.Resource;

import org.apache.struts2.ServletActionContext;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.baidu.bos.domain.Function;
import com.baidu.bos.domain.User;
import com.baidu.bos.service.IFunctionService;
import com.baidu.bos.utils.BOSContext;
import com.baidu.bos.web.action.base.BaseAction;
@Controller
@Scope("prototype")
public class FunctionAction extends BaseAction<Function>{
	@Resource
	private IFunctionService functionService;
	
	//分页查询权限列表:注意这里有2个page属性,如果需要分页的话,需要更改一个
	public String pageQuery(){
		functionService.pageQuery(pageBean);
		this.writeObject2Json(pageBean);
		return NONE;
	}
	
	//查询所有权限
	public String list(){
		List<Function> list = functionService.findAll();
		this.writeObject2Json(list);
		return NONE;
	}
	//根据登录用户查询对应的基本功能菜单
	public String findMenu(){
		User user = BOSContext.getLoginUser();
		List<Function> list = functionService.findMenu(user);
		this.writeObject2Json(list);
		return NONE;
	}
	//查询所有的系统功能菜单
	public String findAdminMenu(){
		User user = BOSContext.getLoginUser();
		List<Function> list = functionService.findAdminMenu(user);
		this.writeObject2Json(list);
		return NONE;
	}
}
